#pragma once

#include "RP6I2CmasterTWI.h"
#define PCF8574_RIGHT_ADDRESS 0x4E

uint8_t pcf_right_port=255;//At power-on, all ports are high!
uint8_t pcf_right_isInitialized=true;

void PCF8574_RIGHT_allOn(){
	I2CTWI_transmitByte(PCF8574_RIGHT_ADDRESS,0b00000000);
}

void PCF8574_RIGHT_allOff(){
	I2CTWI_transmitByte(PCF8574_RIGHT_ADDRESS,0b11111111);
}

void PCF8574_RIGHT_setPorts(uint8_t ports){
	//only update if the ports have changed, that saves a lot of I2C traffic
	if(ports!=pcf_right_port){
		pcf_right_port=ports;
		I2CTWI_transmitByte(PCF8574_RIGHT_ADDRESS,ports);
	}	
}